<template>
  <div>
    <Content>
      <Table border :columns="columns" :data="dataGrid"></Table>
    </Content>
  </div>
</template>
<script>
export default {
  name: "skuLocation",
  data() {
    return {
      columns: [
        {
          title: "仓库名称",
          key: "warehouseName",
        },
        {
          title: "库区名称",
          key: "warehouseAreaName",
        },
        {
          title: "库位名称",
          key: "warehouseLocationName"
        },
        {
          title: "货位编号",
          key: "shelfCode",
        },
        {
          title: "入库数量",
          key: "total",
          sortable: true
        },
        {
          title: "单位",
          key: "skuUom"
        },
        {
          title: "入库时间",
          key: "postTime",
          sortable: true
        }
      ],
      dataGrid: []
    }
  },
  methods: {
    init(shopOrderId,skuId) {
      new this.$rest({
        gateway: 'agroerp',
        service: "agroerp-wms",
        url: "/v1.0/isb/page",
        query: {
          equal: {
            bizOrderId: shopOrderId,
            skuId: skuId
          }
        },
        action: (res) => {
          if (res.data.code === 20000) {
            const data = res.data.data.list[0]
            if(data.shelfJson) {
              let array = JSON.parse(data.shelfJson)
              array.forEach(element => {
                element.postTime = this.$date(data.postTime,'yyyy-MM-dd HH:mm:ss')
              })
              this.dataGrid = array
            } else {
              this.$Notice.warning({
                title: "温馨提示",
                desc: `该商品暂无货位信息`,
              })
            }
          } else {
            this.$Notice.warning({
              title: "获取失败",
              desc: `失败原因：${res.data.msg}`,
            })
          }
        }
      }).get()
    }
  }
}
</script>